

class ModelMixin:
  def to_dict(self):
    #将model对象转化为字典dict
    data={}
    for field in self._meta.fields:
      name=field.attname
      value=self.__dict__[name] #getattr(self.name)
      data[name]=value
    return data